package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.RecyclerView.LayoutParams;
import com.huawei.appgallery.foundation.card.base.bean.BaseDistCardBean;
import com.huawei.appgallery.horizontalcard.api.card.BaseHorizontalItemCard;
import com.huawei.appmarket.framework.widget.TagRenderTextView;
import com.huawei.appmarket.service.store.awk.widget.horizon.HorizontalCardConfig;
import o.cgz;
import o.chy;
import o.epv;
import o.eqx;
import o.evx;
import o.ewm.d;
import o.ewm.h;
import o.ewm.j;

public class HorizontalAppSmallItemCard extends BaseHorizontalItemCard {
    protected int ʻ;
    protected int ʼ;
    protected int ʽ;
    protected ConstraintLayout ˋ;
    private int ॱॱ;
    protected int ᐝ;

    public HorizontalAppSmallItemCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ˏ((ImageView) view.findViewById(j.ʻˊ));
        ˊ((ImageView) view.findViewById(j.ꜞˋ));
        ॱ((TextView) view.findViewById(j.ʽ));
        ˊ((TextView) view.findViewById(j.ˋ));
        this.ˋ = (ConstraintLayout) view.findViewById(j.ʼﾟ);
        ʽ(view);
        Context context = view.getContext();
        this.ʼ = context.getResources().getDimensionPixelSize(d.ˋ);
        this.ॱॱ = context.getResources().getDimensionPixelSize(d.ॱ);
        this.ʽ = ˎ(context) + this.ʼ;
        this.ʻ = (int) ˏ(ˊˋ().getTextSize());
        this.ᐝ = (int) ˏ(ˋˊ().getTextSize());
        return this;
    }

    protected int ˎ(Context context) {
        return epv.ˊ();
    }

    public int ˊ() {
        return h.ʹ;
    }

    public int ˎ() {
        return h.ʹ;
    }

    public void x_() {
        if (this.ˊᐝ instanceof BaseDistCardBean) {
            int ˊ;
            int ˋ;
            CharSequence O_;
            int i;
            BaseDistCardBean baseDistCardBean = (BaseDistCardBean) this.ˊᐝ;
            if (this.ˊᐝ.ॱꜞ() instanceof HorizontalCardConfig) {
                HorizontalCardConfig horizontalCardConfig = (HorizontalCardConfig) this.ˊᐝ.ॱꜞ();
                ˊ = horizontalCardConfig.ˊ();
                ˋ = horizontalCardConfig.ˋ();
            } else {
                ˋ = 1;
                ˊ = 1;
            }
            int ͺ = baseDistCardBean.ͺ();
            this.ʿ.setMaxLines(ˊ);
            String str = "";
            if (ͺ == 4) {
                O_ = baseDistCardBean.O_();
                i = 0;
            } else if (TextUtils.isEmpty(baseDistCardBean.ˏˎ())) {
                r6 = str;
                i = 8;
            } else {
                r6 = baseDistCardBean.ˏˎ();
                i = 0;
            }
            this.ˉ.setVisibility(i);
            if (i == 8) {
                ˋ = 0;
            } else {
                this.ˉ.setMaxLines(ˋ);
                if (this.ˉ instanceof TagRenderTextView) {
                    ((TagRenderTextView) this.ˉ).setData(O_, baseDistCardBean.ˋʻ(), this.ॱॱ);
                } else {
                    this.ˉ.setText(O_);
                }
            }
            ॱ(ˊ, ˋ);
        }
    }

    protected void ॱ(int i, int i2) {
        if (this.ˋ != null) {
            LayoutParams layoutParams = (LayoutParams) this.ˋ.getLayoutParams();
            int i3 = (this.ʽ + (this.ʻ * i)) + (this.ᐝ * i2);
            if (layoutParams != null) {
                layoutParams.height = i3;
            }
        }
    }

    public void ॱ(final chy o_chy) {
        OnClickListener anonymousClass5 = new evx(this) {
            final /* synthetic */ HorizontalAppSmallItemCard ˏ;

            public void ˋ(View view) {
                o_chy.ˏ(0, this.ˏ);
            }
        };
        ʼॱ().setOnClickListener(anonymousClass5);
        ˉ().setOnClickListener(anonymousClass5);
    }

    public void w_() {
        if (!ॱॱ() || TextUtils.isEmpty(this.ˊᐝ.ॱˑ())) {
            eqx.ˏ(this.ʽॱ, this.ˊᐝ.ॱˌ(), "app_default_icon");
        } else {
            eqx.ॱ(this.ʽॱ, this.ˊᐝ.ॱˑ(), "app_default_icon");
        }
        this.ʽॱ.setContentDescription(this.ˊᐝ.v_());
    }

    protected boolean ॱॱ() {
        return false;
    }

    public void ˍ() {
        if (this.ˈ != null) {
            if (this.ˊᐝ instanceof BaseDistCardBean) {
                BaseDistCardBean baseDistCardBean = (BaseDistCardBean) this.ˊᐝ;
                if (baseDistCardBean.ͺ() != 3 || TextUtils.isEmpty(baseDistCardBean.ॱʿ())) {
                    this.ˈ.setVisibility(8);
                    return;
                }
                this.ˈ.setVisibility(0);
                eqx.ˏ(this.ˈ, baseDistCardBean.ॱʿ(), "iconflag");
                return;
            }
            this.ˈ.setVisibility(8);
        }
    }
}
